package com.springboot.jdk.pool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * FixThreadPoolDemo 案例
 *
 * @author: zr
 * @date: 2021-10-15
 */
public class SingleThreadPoolDemo {

    public static void main(String[] args) {
        // 线程池管理器
        ExecutorService executorService = Executors.newSingleThreadExecutor();
        // 10个任务，就通过3个线程来执行
        for (int i = 0; i < 10; i++) {
            executorService.execute(new Runnable() {
                @Override
                public void run() {
                    System.out.println(Thread.currentThread() + ":" + "线程池异步执行任务");
                }
            });
        }

    }
}
